USE [Training]
GO

IF NOT EXISTS (SELECT * from dbo.sysobjects WHERE id = OBJECT_ID(N'dbo.training_api_EmployeeSelect'))
	EXEC('CREATE PROC dbo.training_api_EmployeeSelect AS')
GO

ALTER PROC dbo.training_api_EmployeeSelect
	@EmployeeID		int = null
AS
	SELECT
		EmployeeID,
		FirstName,
		LastName,
		Email,
		SmsNumber,
		ReportsToId,
		DepartmentTreeId,
		IsActive
	FROM
		Employee
	WHERE
		(@EmployeeID IS NULL OR(EmployeeID = @EmployeeID))
		AND IsActive = 1

